<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/public/inc/tags.jsp"%>
<input type="hidden" value="${bookid}" name="bookid">
<input type="hidden" value="${model.id}" name="id">
<input type="hidden" value="${model.chapterid}" name="chapterid">
<div class="form-horizontal">
    <div class="form-group">
        <label class="control-label col-md-2">第几章节</label>
        <div class="col-md-10">
            <input type="text" id="chapternumber" name="chapternumber" class="form-control" placeholder="请输入章节"
                   value="${model.chapternumber}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">章节名称</label>
        <div class="col-md-10">
            <input type="text" id="chaptername" name="chaptername" class="form-control" placeholder="请输入章节名称"
                   value="${model.chaptername}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">点击量</label>
        <div class="col-md-10">
            <input type="text" id="virtual_click_count" name="virtual_click_count" class="form-control" placeholder="请输入点击量"
                   value="${model.virtual_click_count}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">音频作者</label>
        <div class="col-md-10">
            <input type="text" id="videoauthor" name="videoauthor" class="form-control" placeholder="请输入章节音频作者"
                   value="${model.videoauthor}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">章节音频</label>
        <div class="col-md-10">
            <input type="hidden" name="chaptervideo" value="${model.chaptervideo}"/>
            <input type="file" id="chaptervideo" accept="audio/mpeg" name="fileUrl" class="btn btn-primary">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">音频时长</label>
        <div class="col-md-10">
            <input type="text" id="chapterduration" name="chapterduration" class="form-control" placeholder="音频时长"
                   value="${model.chapterduration}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">音频大小</label>
        <div class="col-md-10">
            <input type="text" id="chaptersize" name="chaptersize" class="form-control" placeholder="音频大小"
                   value="${model.chaptersize}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">试读</label>
        <div class="col-md-10">
            <select name="readable" class="form-control">
                <option value="-1">请选择</option>
                <option value="0" <c:if test="${model.readable==0}"> selected="selected"</c:if>>否</option>
                <option value="1" <c:if test="${model.readable==1}"> selected="selected"</c:if>>是</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">排序</label>
        <div class="col-md-10">
            <input type="text" name="sort" class="form-control" placeholder="请输入值"
                   value="${model.sort}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-md-2">内容</label>
        <div class="col-md-10">
            <textarea id="content" name="content" style="width:100%;height: 40%">${model.content}</textarea>
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <button type="submit" class="btn btn-primary">
                <i class="fa fa-floppy-o"></i> 保存
            </button>
        </div>
    </div>
</div>
<jsp:include page="/public/inc/ueditor.jsp"/>
<script type="text/javascript">
    $(document).ready(function () {
        UE.getEditor('content');

        $("#form2").bootstrapValidator({
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                chapternumber: {
                    validators: {
                        notEmpty: {
                            message: '不能为空'
                        },
                        stringLength: {
                            max: 225,
                            message: '长度过长'
                        }

                    }
                },
                chaptername: {
                    validators: {
                        stringLength: {
                            max: 225,
                            message: '长度过长'
                        }
                    }
                },
                sort: {
                    validators: {
                        notEmpty: {
                            message: '不能为空'
                        }
                    }
                },
                videoauthor: {
                    validators: {
                        stringLength: {
                            max: 225,
                            message: '长度过长'
                        }
                    }
                },
                chapterduration: {
                    validators: {
                        stringLength: {
                            max: 50,
                            message: '长度过长'
                        }
                    }
                },
                chaptersize: {
                    validators: {
                        stringLength: {
                            max: 50,
                            message: '长度过长'
                        }

                    }
                },
                readable: {
                    validators: {
                        regexp: {
                            regexp: /^[0-1]*$/,
                            message: '必须选中一个'
                        }
                    }
                }
            }
        });
    });
</script>